	import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.ArrayList;
	 
	public class ValidDate {
	    public static void main(String[] args) {
	        DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
	        ArrayList<SimpleDateFormat> dateFormats = new ArrayList<SimpleDateFormat>();
	        dateFormats.add(new SimpleDateFormat("yyyy-MM-dd"));
	        dateFormats.add(new SimpleDateFormat("yyyy MM dd"));
	        dateFormats.add(new SimpleDateFormat("yyyy.MM.dd"));
	        //
	        // Input to be parsed should strictly follow the defined date format
	        // above.
	        //
	        format.setLenient(false);
	 
	        String date = "18/12/2007";
	        try {
	            format.parse(date);
	        } catch (ParseException e) {
	            System.out.println("Date " + date + " is not valid according to " +
	                    ((SimpleDateFormat) format).toPattern() + " pattern.");
	        }
	    }
	}